#ifndef __TEST_H_
#define __TEST_H_

#include <linux/types.h>
#include <linux/version.h>

#include <sys/mman.h>
#include <sys/wait.h>

#include <assert.h>
#include <err.h>
#include <errno.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <cuda_runtime_api.h>
#include <cuda_runtime.h>
#include <helper_functions.h>
#include <helper_cuda.h>

#define MAX_DEVICES  8
#define PROC_PER_DEV 1
#define BUFSIZE   4096

typedef enum {
   FALSE = 0,
   TRUE  = 1
} boolean;

struct ipcdevices_t {
   int count;
   int ordinals[MAX_DEVICES];
};

struct ipccuda_t {
   int device;
   pid_t pid;
   cudaIpcEventHandle_t event_handle;
   cudaIpcMemHandle_t mem_handle;
};

struct ipcbarrier_t {
   int count;
   bool sense;
   bool exit;
};

int main(int, char **);
void proc_barrier(int);
void get_device_count(ipcdevices_t *);
void runtest_multikernel(ipccuda_t *, int, int);

ipcbarrier_t *barrier;
bool proc_sense;

#endif
